package cn.tedu.sp04.feign;

import cn.tedu.sp01.pojo.Item;
import cn.tedu.sp01.util.JsonResult;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class ItemFeignClientFB implements ItemFeignClient{
    @Override
    public JsonResult<List<Item>> getItems(String orderId) {
        if (Math.random()>0.5){
            List<Item> cacheItems = new ArrayList<>();
            cacheItems.add(new Item(1,"缓存商品1",10));
            cacheItems.add(new Item(2,"缓存商品2",20));
            cacheItems.add(new Item(3,"缓存商品3",30));
            return JsonResult.ok(cacheItems);
        }
        return JsonResult.err("获取商品失败");
    }

    @Override
    public JsonResult<?> decreaseNumber(List<Item> items) {
        return JsonResult.err("扣减库存失败");
    }
}
